package com.ctshk.common.log.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.common.log.entity.CommodityHotWord;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

/**
 * TODO
 *
 * @author 黄利斌
 * @date 2021/5/25 4:56 下午
 */
public interface CommodityHotWordMapper extends BaseMapper<CommodityHotWord> {
    /**
     * 查询搜索热词关键字
     * @param word
     * @return
     */
    @Select("SELECT  id,words,number,create_id,modified_id,gmt_create,gmt_modified,is_deleted  FROM `ctshk-goods`.t_commodity_hot_word     WHERE (words = #{word})")
    CommodityHotWord selectByWord(String word);

    /**
     * 新增热词数据
     * @param commodityHotWord
     */
    @Insert({"<script>" +
            "INSERT INTO `ctshk-goods`.t_commodity_hot_word  ( " +
            "<if test='id!=null'>id,</if> " +
            "<if test='words!=null'>words,</if>" +
            "<if test='number!=null'>number,</if>" +
            "<if test='createId!=null'>create_id,</if> " +
            "<if test='gmtCreate!=null'>gmt_create,</if> " +
            "<if test='gmtModified!=null'>gmt_modified,</if> " +
            "<if test='isDeleted!=null'>is_deleted</if> )  " +
            "VALUES (" +
            "<if test='id!=null'>#{id},</if> " +
            "<if test='words!=null'>#{words}, </if>" +
            "<if test='number!=null'>#{number}, </if>" +
            "<if test='createId!=null'>#{createId},</if>" +
            "<if test='gmtCreate!=null'>#{gmtCreate},</if>" +
            "<if test='gmtModified!=null'>#{gmtModified},</if>" +
            "<if test='isDeleted!=null'>#{isDeleted}</if>)" +
            "</script>"})
    void saveEntity(CommodityHotWord commodityHotWord);

}
